<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var age = prompt("请输入年龄");
        age = parseInt(age);
        if (age>= 18) {
            document.write( '<img src="a.jpg" ');
        }else {
            alert("用户年龄太小");
        }

    </script>
</head>
<body>

</body>
</html>